<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册币转账</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/Theme1/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/static/plupload/upfiless.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/Theme1/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/Theme1/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <style>
        .span-notice {
            margin-top: 7px;
            display: block;
            color: red;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>注册币转账</h5>
                    <div class="ibox-tools">

                    </div>
                </div>
                <div class="ibox-content">
                    <form method="post" action="zhuanZOP" class="form-horizontal" id="form-admin-add"
                          enctype="multipart/form-data" onsubmit="return ckForm()">

                        <div class="form-group">
                            <label class="col-sm-1 control-label">当前会员编号</label>
                            <div class="col-sm-3">
                                <{$userarr.loginname}>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-1 control-label">当前注册币</label>
                            <div class="col-sm-3">
                                <{$userarr.amount}>
                                <input type="hidden" value="<{$userarr.amount}>" id="bdAmount"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">对方会员账号</label>
                            <div class="col-sm-3">
                                <input type="text" value="" id="toUser" name="toUser" class="form-control"
                                       onBlur="cktouser(this.value)"/>
                                <span id="span_user_notice" class="span-notice"></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-1 control-label">要转账的金额</label>
                            <div class="col-sm-3">
                                <input type="number" name="txt_baodanCoin" id="txt_baodanCoin" class="form-control"
                                       onBlur="ckbaodan(this.value)" value="" placeholder="请输入100的整数"/>
                                <input type="hidden" value="<{$int}>" id="user_amount_int"/>
                                <span id="amount_notice" class="amount_notice"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" id="btnsubmit">确定兑换</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Theme1/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Theme1/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Theme1/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Theme1/js/plugins/iCheck/icheck.min.js"></script>

<script type="text/javascript" src="__PUBLIC__/Theme1/check/js/jquery.validate.min.js"></script>

<script type="text/javascript" src="__PUBLIC__/Theme1/check/js/messages_zh.min.js"></script>

<script type="text/javascript" src="__PUBLIC__/Theme1/check/js/validate-methods.js"></script>
<script type="text/javascript" src="__PUBLIC__/Theme1/lib/webuploader/0.1.5/webuploader.min.js"></script>

<script>
    $(document).ready(function () {
        $("#btnsubmit").attr("disabled", "disabled");
//        $("#toUser").focus();
        $(".i-checks").iCheck({checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green",})
    });
</script>
<script type="text/javascript">
    function cktouser(thisvalue) {
        jQuery.ajax({
            url: "__URL__/check_touser_pp",
            type: "get",
            data: {username: thisvalue},
            dataType: "text",
            success: function (data) {
                if (data == "nouser") {
                    $("#span_user_notice").html("&nbsp;&nbsp;&nbsp;&nbsp;不存在此用户");
                    $("#toUser").val("").focus();
                    $("#btnsubmit").attr("disabled", "disabled");
                }
                else {
                    $("#span_user_notice").html(data);
                   // $("#span_user_notice").html(data.truename);
                    $("#btnsubmit").removeAttr("disabled");
                }
            }
        });
    }

    function ckbaodan() {
        var inputCoin = $("#txt_baodanCoin").val();
        var bdAmount = $("#user_amount_int").val();
        if(!(inputCoin%100==0))
        {
            $("#amount_notice").html("&nbsp;&nbsp;请输入100的整数");
            $("#txt_baodanCoin").val("").focus();
            $("#btnsubmit").attr("disabled", "disabled");
        }else{
            $("#amount_notice").html("");
            $("#btnsubmit").removeAttr("disabled");
        }
        if (parseInt(inputCoin) > parseInt(bdAmount)) {
            $("#amount_notice").html("&nbsp;&nbsp;最多可转账"+bdAmount);
            $("#txt_baodanCoin").val(bdAmount);
        }
        if(parseInt(bdAmount)==0){
            $("#amount_notice").html("&nbsp;&nbsp;转账注册币不足");
            $("#btnsubmit").attr("disabled", "disabled");
        }
    }

    function ckForm() {
        var inputCoin = $("#txt_baodanCoin").val();
        var bdAmount = $("#bdAmount").val();

        if (parseInt(inputCoin) < 0) {
            alert("金额输入有误");
            return false;
        }

        if (parseInt(inputCoin) > parseInt(bdAmount)) {
            alert("金额输入有误");
            return false;
        }
    }


</script>

</body>

</html>
